﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:dataControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
    xmlns:appControls="clr-namespace:Arch.Samples.RiaServices.Controls"
    xmlns:loginWindow="clr-namespace:Arch.Samples.RiaServices.LoginUI"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:tk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input" 
    xmlns:helper="clr-namespace:Arch.Samples.RiaServices.Helpers">

    <DataTemplate x:Key="AdminButtons">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Style="{StaticResource AddButton}" Command="{Binding AddCommand}" />
            <Button Grid.Column="1" Style="{StaticResource EditButton}" Command="{Binding EditCommand}" CommandParameter="{Binding CurrentItem}" />
            <Button Grid.Column="2" Style="{StaticResource DeleteSelectedButton}" Command="{Binding DeleteSelectedCommand}" />
            <Button Grid.Column="3" Style="{StaticResource SaveButton}" Command="{Binding SubmitCommand}" />
            <Button Grid.Column="4" Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="NoEditAdminButtons">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Style="{StaticResource AddButton}" Command="{Binding AddCommand}" />
            <Button Grid.Column="1" Style="{StaticResource DeleteSelectedButton}" Command="{Binding DeleteSelectedCommand}" />
            <Button Grid.Column="2" Style="{StaticResource SaveButton}" Command="{Binding SubmitCommand}" />
            <Button Grid.Column="3" Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="Grid">
        <data:DataGrid x:Name="Grid" ItemsSource="{Binding CollectionViewSource.View}" 
                       helper:DataGridMultipleSelection.SelectedItemsSource="{Binding SelectedItems}">
            <data:DataGrid.Resources>
                <helper:DataContextProxy x:Key="DataContext" />
            </data:DataGrid.Resources>
        </data:DataGrid>
    </DataTemplate>
    
    <DataTemplate x:Key="ReadOnlyGrid">
        <data:DataGrid x:Name="Grid" ItemsSource="{Binding CollectionViewSource.View}" IsReadOnly="True"
                       helper:DataGridMultipleSelection.SelectedItemsSource="{Binding SelectedItems}">
            <data:DataGrid.Resources>
                <helper:DataContextProxy x:Key="DataContext" />
            </data:DataGrid.Resources>
        </data:DataGrid>
    </DataTemplate>



</ResourceDictionary>
